﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddProduct.aspx.cs" Inherits="admin_AddProduct" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="js/themes/gray/easyui.css" />
    <link rel="stylesheet" type="text/css" href="js/themes/icon.css" />
    <script type="text/javascript" src="../js/jquery-1.4.1.min.js"></script>
    <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
</head>
<body>
    <form id="oForm" method="post">
    <table style="font-size: 13px;">
        <tr>
            <td>
                产品名称：
            </td>
            <td colspan="5">
                <input style="width: 400px;" id="pname" name="pname" class="easyui-validatebox txt"
                    required="true" runat="server" />&nbsp;&nbsp; <a class="easyui-linkbutton" plain="true"
                        iconcls="icon-ok" onclick="Btn_Submit()">提交</a>
            </td>
        </tr>
        <tr>
            <td>
                产品类别：
            </td>
            <td>
                <input id="ptype" name="ptype" required="true" runat="server" editable="false" />
            </td>
            <td>
                产品价格：
            </td>
            <td>
                <input id="pprice" name="pprice" runat="server" class="txt easyui-numberbox" style="width: 80px;" />
            </td>
            <td>
                产品状态：
            </td>
            <td>
                <select id="pstatus" name="pstatus" runat="server" class="easyui-combobox" editable="false"
                    panelheight="auto">
                    <option value="1">热卖</option>
                    <option value="0">缺货</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                产品描述：
            </td>
            <td colspan="5">
                <input name="content" id="content" style="display: none;" runat="server" />
                <iframe src="edit/editor.htm?id=content&ReadCookie=0" frameborder="0" marginheight="0"
                    marginwidth="0" scrolling="No" width="621" height="457"></iframe>
            </td>
        </tr>
    </table>
    <input type="hidden" id="pId" name="pId" runat="server" value="" />
    </form>
</body>
</html>
<script type="text/javascript">
    function Btn_Submit() {
        var url = "";
        if ($("#pId").val() == "") {
            url = "Operation.ashx?cmd=addProduct";
        }
        else {
            url = "Operation.ashx?cmd=updateProduct";
        }
        $("#oForm").form("submit", {
            url: url,
            onSubmit: function () {
                var check = $(this).form('validate');
                return check;
            },
            success: function (data) {
                var result = eval("(" + data + ")");
                if (result.success) {
                    parent.closeTab();
                } else {
                    $.messager.alert('提示信息', result.msg, 'error');
                }
            }
        });
    }
    $(document).ready(function () {
        $('#pprice').numberbox({
            min: 0,
            precision: 2
        });
        $('#ptype').combobox({
            url: 'Operation.ashx?cmd=getProductsType',
            panelHeight: "auto",
            valueField: 'val',
            textField: 'txt'
        });
    })
</script>
